<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合格证信息</title>
<jsp:include page="../../import.jsp" flush="true" />
<style>
.moreGps{
width:398px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
-ms-border-radius:4px;
-khtml-border-radius:4px;
border-radius:4px;
}
</style>
</head>
<body class="iframeBody">
    <div class="Wrapper">
		<div id="pageInTab" class="pageInTab">
			<form id="prj_prd_veh_info_form">
			    <div class="fieldset1 tabel_col tabel_col_s clearFix">
                    <c:if test="${detailFlag!=true }">
                        <div class="fieldBox col_100">
                            <div class="label col_100">合格证上传</div>
                            <div class="field">
                                <jsp:include
                                    page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload5.jsp"
                                    flush="true">
                                    <jsp:param name="filePath" value="capital/capPayInfo" />
                                </jsp:include>
                            </div>
                        </div>
                    </c:if>
				</div>
				
				<div class="sqPanel">
					<div class="sqPanel_head inL">
						<span>合格证扫描照片信息</span>
					</div>
					<table class="table_full tbl_1">
						<tbody id="imgTable4">
		
						</tbody>
					</table>
				</div>

                <div class="btnsBox" align="center">
                    <span id="qrVeh" class="sq-button sq-button-round"  onclick="qrVeh();">合格证解析</span>
                    <span id="ocrVeh" class="sq-button sq-button-round"  onclick="ocrVeh(1);">OCR识别</span>
					<span class="requiredSymbol">(OCR只识别第一张)</span>
                    <span class="requiredSymbol" id="ocrVehinfo"></span>
                </div>
				<div class="fieldset1 tabel_col clearFix">
					<div class="fieldBox col_50">
						<div class="label">客户名称</div>
						<div class="field">
							<span>${vehInfo.cstNm}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合同号</div>
						<div class="field">
							<span><a href="javascript:prjDetailBtn(${vehInfo.prjId});">${vehInfo.lsCntNo}</a></span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">支付表号</div>
						<div class="field">
							<span><a href="javascript:payDetailBtn(' ' ,'${vehInfo.paySchId}','${vehInfo.prjPrdId }','${vehInfo.prjId}');">
                                ${vehInfo.paySchNo}</a></span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">租赁物名称</div>
						<div class="field">
							<span>${vehInfo.prdNm}</span>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">租赁物型号</div>
						<div class="field">
							<span id="prjPrdMdl">${vehInfo.prjPrdMdl}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合格证型号</div>
						<div class="field">
							<input name="prdMdl" id="prdMdl" type="text" class="ui-textbox"
								onblur="checkPrdMdl();" value="${vehInfo.prdMdl}" validate="{required:true}"/>
                            <span class="requiredSymbol">*</span>
                            <span id="prdMdlText"></span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">租赁物发动机型号</div>
						<div class="field">
							<span id="prjEngMdl">${vehInfo.prjEngMdl}</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合格证发动机型号</div>
						<div class="field">
							<input name="engMdl" id="engMdl" type="text" class="ui-textbox" onblur="checkEngMdl();"
                                   value="${vehInfo.engMdl }" validate="{required:true}"/>
                            <span class="requiredSymbol">*</span>
							<span id="engMdlText"></span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">发动机号</div>
						<div class="field">
							<input name="engNo" id="engNo" type="text" class="ui-textbox"
								value="${vehInfo.engNo }" validate="{required:true}"/>
                            <span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合格证编号</div>
						<div class="field">
							<input name="certNo" id="certNo" type="text" class="ui-textbox"
                                   value="${vehInfo.certNo }" validate="{required:true}"/>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">发证日期</div>
						<div class="field">
							<c:if test="${detailFlag==true }">
								<span id="certDtTxt">${vehInfo.certDt}</span>
							</c:if>
							<c:if test="${detailFlag!=true }">
								<input name="certDt" id="certDt" type="text" class="ui-datepicker" value="${vehInfo.certDt}"/>
							</c:if>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">车辆制造企业名称</div>
						<div class="field">
							<input name="mfrNm" id="mfrNm" type="text" class="ui-textbox" value="${vehInfo.mfrNm}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">车辆品牌</div>
						<div class="field">
							<input name="vehBr" id="vehBr" type="text" class="ui-textbox" value="${vehInfo.vehBr }"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">车辆名称</div>
						<div class="field">
							<input name="vehNm" id="vehNm" type="text" class="ui-textbox" value="${vehInfo.vehNm }"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">车架号</div>
						<div class="field">
							<input name="vin" id="vin" type="text" class="ui-textbox" value="${vehInfo.vin}"
                                   validate="{required:true}" onblur="validateVin(this)"/>
                            <input name="vinValidRes" id="vinValidRes" type="hidden" class="ui-textbox"
								value="${vehInfo.vinValidRes}" validate="{required:true}"/>
							<span class="requiredSymbol">*</span>
                            <span class="requiredSymbol" id="vinValidationResult">${vehInfo.vinValidResNm}</span>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">车身颜色</div>
						<div class="field">
							<input name="carCl" id="carCl" type="text" class="ui-textbox" value="${vehInfo.carCl }"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">底盘型号</div>
						<div class="field">
							<input name="chsMdl" id="chsMdl" type="text" class="ui-textbox" value="${vehInfo.chsMdl}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">底盘ID</div>
						<div class="field">
							<input name="chsId" id="chsId" type="text" class="ui-textbox" value="${vehInfo.chsId}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">底盘合格证编号</div>
						<div class="field">
							<input name="chsCertNo" id="chsCertNo" type="text" class="ui-textbox" value="${vehInfo.chsCertNo}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">燃料种类</div>
						<div class="field">
							<input name="fuelTyp" id="fuelTyp" type="text" class="ui-textbox" value="${vehInfo.fuelTyp}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">排量（ml）</div>
						<div class="field">
							<input name="outVol" id="outVol" type="text" class="ui-textbox" value="${vehInfo.outVol}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">功率（kW）</div>
						<div class="field">
							<input name="maxKw" id="maxKw" type="text" class="ui-textbox" value="${vehInfo.maxKw}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">油耗</div>
						<div class="field">
							<input name="oilCns" id="oilCns" type="text" class="ui-textbox" value="${vehInfo.oilCns}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">外廓尺寸（mm）</div>
						<div class="field">
							<input name="outlineSz" id="outlineSz" type="text" class="ui-textbox" value="${vehInfo.outlineSz}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">货厢内部尺寸（mm）</div>
						<div class="field">
							<input name="cntrSz" id="cntrSz" type="text" class="ui-textbox" value="${vehInfo.cntrSz}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">钢板弹簧片数（片）</div>
						<div class="field">
							<input name="leafSprNum" id="leafSprNum" type="text" class="ui-textbox" value="${vehInfo.leafSprNum}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">轮胎数</div>
						<div class="field">
							<input name="whlNum" id="whlNum" type="text" class="ui-textbox" value="${vehInfo.whlNum}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">轮胎规格</div>
						<div class="field">
							<input name="whlSpec" id="whlSpec" type="text" class="ui-textbox" value="${vehInfo.whlSpec}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">轮距(前/后)（mm）</div>
						<div class="field">
							<input name="thread" id="thread" type="text" class="ui-textbox" value="${vehInfo.thread}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">轴距（mm）</div>
						<div class="field">
							<input name="whlBase" id="whlBase" type="text" class="ui-textbox" value="${vehInfo.whlBase}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">轴荷（kg）</div>
						<div class="field">
							<input name="axleLoad" id="axleLoad" type="text" class="ui-textbox" value="${vehInfo.axleLoad}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">轴数</div>
						<div class="field">
							<input name="axisNum" id="axisNum" type="text" class="ui-textbox" value="${vehInfo.axisNum}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">转向形式</div>
						<div class="field">
							<input name="strTyp" id="strTyp" type="text" class="ui-textbox" value="${vehInfo.strTyp}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">总质量</div>
						<div class="field">
							<input name="totWgt" id="totWgt" type="text" class="ui-textbox" value="${vehInfo.totWgt}"/>
						</div>
					</div>

					<div class="fieldBox col_50">
						<div class="label">整备质量（kg）</div>
						<div class="field">
							<input name="curbWgt" id="curbWgt" type="text" class="ui-textbox" value="${vehInfo.curbWgt}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">额定载质量（kg）</div>
						<div class="field">
							<input name="ratedWgt" id="ratedWgt" type="text" class="ui-textbox" value="${vehInfo.ratedWgt}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">载质量利用系数</div>
						<div class="field">
							<input name="wgtCoe" id="wgtCoe" type="text" class="ui-textbox" value="${vehInfo.wgtCoe}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">准牵引总质量（kg）</div>
						<div class="field">
							<input name="traTotWgt" id="traTotWgt" type="text" class="ui-textbox" value="${vehInfo.traTotWgt}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">半挂车鞍座最大允许总质量（kg）</div>
						<div class="field">
							<input name="semiMaxWgt" id="semiMaxWgt" type="text" class="ui-textbox" value="${vehInfo.semiMaxWgt}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">驾驶室准乘人数（人）</div>
						<div class="field">
							<input name="cabSeatQty" id="cabSeatQty" type="text" class="ui-textbox" value="${vehInfo.cabSeatQty}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">额定载客（人）</div>
						<div class="field">
							<input name="ratedSeatQty" id="ratedSeatQty" type="text" class="ui-textbox" value="${vehInfo.ratedSeatQty}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">最高设计车速（km/h）</div>
						<div class="field">
							<input name="maxSpd" id="maxSpd" type="text" class="ui-textbox" value="${vehInfo.maxSpd}"/>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">车辆制造日期</div>
						<div class="field">
							<input name="proDt" id="proDt" type="text" class="ui-datepicker" value="${vehInfo.proDt}"/>
						</div>
					</div>
					<div class="fieldBox col_100">
						<div class="label">排放标准</div>
						<div class="field">
							<input name="emiStd" id="emiStd" type="text" class="ui-textbox" value="${vehInfo.emiStd}"/>
						</div>
					</div>
					<div class="fieldBox col_100">
						<div class="label">备注</div>
						<div class="field">
							<textarea name="dtlRem" id="dtlRem" rows="4"
								class="ui-textarea l-textarea" style="width: 80%" value="">${vehInfo.dtlRem }</textarea>
						</div>
					</div>
					<!--GPS卡号 -->
					<div class="fieldBox col_100">
						<div class="sqPanel_body">
							<div id="gpsInfoCfgGrid" class="sq-grid"></div>
							<div>
								<span id="gpsInfoCfgGrid_comment"></span>
							</div>
						</div>
					</div>

					<div class="fieldBox col_50" style="display: none">
						<div class="field">
							<input name="vehId" id="vehId" type="text" value="${vehInfo.id }"/>
							<input name="dtlId" id="dtlId" type="text" value="${vehInfo.dtlId }"/>
						</div>
					</div>
					<div class="fieldBox col_100">
						<div class="label">挂靠公司</div>
						<div class="field">
							<span> <input name="lnkCompNm" id="lnkCompNm" type="text"
								class="ui-textbox" value="${vehInfo.prjPrdDtl.lnkCompNm}" readonly="readonly"/></span>
                            <input name="lnkCompId" id="lnkCompId" type="hidden" value="${vehInfo.prjPrdDtl.lnkCompId}"/>
                            <span id="chooseLnkComp" class="sq-button sq-button-hasicon"
								onclick="choosePrjLnkComp();"><i class="sqBtnIco_1"></i>更改</span>
							<span id="clearLnkComp" class="sq-button sq-button-hasicon"
								onclick="clearLnkComp();"><i class="sqBtnIco_7"></i>移除</span>
						</div>
					</div>
				</div>
                <%--<div class="fieldset1 tabel_col tabel_col_s clearFix">
                        <!-- <div class="caption">
                                    <span class="title">合格证扫描照片信息 </span>
                                </div> -->
                        <c:if test="${detailFlag!=true }">
                            <div class="fieldBox col_100">
                                <div class="label col_100">其他资料上传</div>
                                <div class="field">
                                    <jsp:include
                                        page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp"
                                        flush="true">
                                        <jsp:param name="filePath" value="capital/capPayInfo" />
                                    </jsp:include>
                                    <input id="tabNm" name="tabNm" type="hidden"
                                        value="PRJ_PRD_DTL"> <input id="pkId" name="pkId"
                                        type="hidden" value="${dtlId}">
                                </div>
                            </div>
                        </c:if>

                </div>

                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>其他资料照片信息</span>
                    </div>
                    <table class="table_full tbl_1">
                        <tbody id="imgTable">

                        </tbody>
                    </table>
                </div>--%>
			</form>
		</div>
		<div class="btnsBox">
            <span id="prj_prd_veh_info_add_btn_id" class="sq-button sq-button-round" onclick="savePrjPrdVin();">保存</span>
        </div>
	</div>
<script type="text/javascript">

    var gpsInfoCfgGrid = null;//GPS卡号明细
    var id = '${id}';// 当前记录id
    var detailFlag = '${detailFlag}';
    var dtlId = '${dtlId}';
    var buOrgCd='${buOrgCd}';
    var LSvin = '${LSvin}';//查询车架号历史数据
    var prjTypCd = "${prjTypCd}";//项目类型
    var prdStsCd = "${prdStsCd}";//资产状态
    var isGpsNode = "${isGpsNode}";//是否风控审批GPS节点，0-否，1-是
    var audStsCd = "${vehInfo.audStsCd}";//合格证审核状态
    var gpsAudStsCd = "${gpsAudStsCd}";//GPS审核状态
    var wait_dialog;
    var absLocPath = '${filePath}';
    var filePathTemp = "";
    var noLinkAction = '${noLinkAction}';
	var noLinkButton = '${noLinkButton}';
	var cstMgrOrgCd = '${cstMgrOrgCd}'; // 客户经理组织机构代码
	var prjPrdChangeFlag = '${prjPrdChangeFlag}'; // 换车标志
	var prjId = '${prjId}';

	var reqNum = 0;// 记录合格证解析请求次数
	var qrFlag = false;// 记录是否解析成功
	var ocrFlag = false;// 记录是否识别成功
	var chgFileFlag = false;// 是否重新上传了图片

	var gpsDevice;//GPS账号下未使用的设备

	function hideLink() {
		if (noLinkAction != null && noLinkAction == 'true') {
			$("#chooseLnkComp").hide();
			$("#clearLnkComp").hide();
		}
		if (noLinkButton != null && noLinkButton == 'true') {
			$("#chooseLnkComp").hide();
			$("#clearLnkComp").hide();
		}
	}

    function ocrVeh(flag){
		if (qrFlag) {// 未更新图片且合格证已解析
			top.$.ligerDialog.SQalert({content:"合格证信息已存在，不允许OCR识别",SQ_type: "error"});
			return ;
		}
		//如果已经上传过图片不再校验只检验第一次上传flag=1不判断
        if(flag == 0 && absLocPath != ''){
            return ;
        }
        //本次页面只支持一次OCR识别，若想再次识别，需更换图片或刷新页面重试
        if (StringUtils.isNotEmpty(absLocPath) && absLocPath == filePathTemp) {
            top.$.ligerDialog.SQalert({content:"已进行过OCR识别",SQ_type: "error"});
            return ;
        }
        if(StringUtils.isNotEmpty(absLocPath)){
            $.ajax({
                type: 'get',
                dataType:'json',
                url: '<%=path%>/project/prjprdvehinfo/ocrVeh.do?url='+absLocPath,
                success:function(msg){
                    if(msg.success == 1){
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                        initVeh(msg.data);
						ocrFlag = true;
                    }else{
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                    }
                    $("#ocrVehinfo").html(msg.info);
                    filePathTemp = absLocPath;
                }
            });
        } else {
            top.$.ligerDialog.SQalert({content: "请先上传图片",SQ_type: "error"});
            return ;
        }
    }

	function qrVeh(){
		if(StringUtils.isNotEmpty(${vehInfo.id}) && !chgFileFlag){ // 存在合格证信息，且未更换合格证图片
			top.$.ligerDialog.SQalert({content:"合格证信息已存在，不允许二次解析",SQ_type: "error"});
			return ;
		}
		if(StringUtils.isEmpty(absLocPath)){
			top.$.ligerDialog.SQalert({content:"请先上传合格证信息",SQ_type: "error"});
			return ;
		}

		var qr_dialog = $.ligerDialog.SQopen({
			width: 400,
			height: 150,
			title : '合格证解析',
			allowClose: false,
			content: '<div id="qrDiv"><p>合格证串码：<input name="qr" id="qr" type="text" class="ui-textbox" /></p>\n' +
					'<p style="color:red">提示：狮桥助手首页扫一扫扫描合格证二维码获取合格证串码</p></div>',
			fixButtons: true, //固定按钮到底部
			onOk: function () {
				var qrStr = $("#qr").val();
				if(StringUtils.isEmpty(qrStr)){
					$.ligerDialog.SQalert({content: "串码不能为空", SQ_type: "warning"});
					return;
				}
				qr_dialog.close();
				var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
				$.ajax({
					type: 'post',
					dataType:'json',
					data: {"qrStr":qrStr},
					url: '<%=path%>/project/prjprdvehinfo/getVehInfoByQR.do',
					success:function(msg){
						reqNum++;
						wait_dialog.close();
						if(msg.success == 1){//解析成功
							top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							initVehByQR(msg.data);
							qrFlag = true;
						}else{//解析失败
							$.ligerDialog.SQalert({content: msg.info, SQ_type: "warning"});
						}
					},
					error:function(xhr){
						wait_dialog.close();
						$.ligerDialog.SQalert({content: "服务器错误", SQ_type: "warning"});
					}
				})
			}
		});
	}

    function  initVeh(data){
        if(data.prjPrdVehInfoDTO.certNo!=''){
            $("#certNo").val(data.prjPrdVehInfoDTO.certNo);//合格证编号
        }
        if(data.prjPrdVehInfoDTO.vin!=''){
            $("#vin").val(data.prjPrdVehInfoDTO.vin);//车架号
            validateVin($("#vin").val());
        }
        if(data.prjPrdVehInfoDTO.vehNm!=''){
            $("#vehNm").val(data.prjPrdVehInfoDTO.vehNm);//车辆品牌/车辆名称
        }
        if(data.prjPrdVehInfoDTO.cntrSz!=''){
            $("#cntrSz").val(data.prjPrdVehInfoDTO.cntrSz);//货箱内部尺寸
        }
        if(data.prjPrdVehInfoDTO.maxKw!=''){
            $("#maxKw").val(data.prjPrdVehInfoDTO.maxKw);//功率
        }
        if(data.prjPrdVehInfoDTO.fuelTyp!=''){
            $("#fuelTyp").val(data.prjPrdVehInfoDTO.fuelTyp);// 燃油种类
        }
        if(data.prjPrdVehInfoDTO.emiStd!=''){
            $("#emiStd").val(data.prjPrdVehInfoDTO.emiStd);//排放标准
        }
        if(data.prjPrdVehInfoDTO.whlNum!=''){
            $("#whlNum").val(data.prjPrdVehInfoDTO.whlNum);//轮胎数
        }
        if(data.prjPrdVehInfoDTO.engNo!=''){
            $("#engNo").val(data.prjPrdVehInfoDTO.engNo);//发动机编号
        }
        if(data.prjPrdVehInfoDTO.engMdl!=''){
            $("#engMdl").val(data.prjPrdVehInfoDTO.engMdl);//发动机型号
        }
        if(data.prjPrdVehInfoDTO.chsMdl!=''){
            $("#chsMdl").val(data.prjPrdVehInfoDTO.chsMdl);//底盘型号/底盘ID
        }
        if(data.prjPrdVehInfoDTO.axisNum!=''){
            $("#axisNum").val(data.prjPrdVehInfoDTO.axisNum);//轴数
        }
    }

	function  initVehByQR(data){
		if(data.prdMdl!=''){
			$("#prdMdl").val(data.prdMdl);//合格证型号
		}
		if(data.engMdl!=''){
			$("#engMdl").val(data.engMdl);//发动机型号
		}
		if(data.engNo!=''){
			$("#engNo").val(data.engNo);//发动机号
		}

		if(data.certNo!=''){
			$("#certNo").val(data.certNo);//合格证编号
		}
		if(data.certDt!=''){
			$("#certDt").val(DateUtils.formatDate(new Date(data.certDt), DateUtils.YYYY_MM_DD));//发证日期
		}
		if(data.mfrNm!=''){
			$("#mfrNm").val(data.mfrNm);//车辆制造企业名称
		}
		if(data.vehBr!=''){
			$("#vehBr").val(data.vehBr);//车辆品牌
		}
		if(data.vehNm!=''){
			$("#vehNm").val(data.vehNm);//车辆品牌/车辆名称
		}

		if(data.vin!=''){
			$("#vin").val(data.vin);//车架号
			validateVin($("#vin").val());
		}
		if(data.carCl!=''){
			$("#carCl").val(data.carCl);//车身颜色
		}
		if(data.chsMdl!=''){
			$("#chsMdl").val(data.chsMdl);//底盘型号
		}
		if(data.chsId!=''){
			$("#chsId").val(data.chsId);//底盘ID
		}
		if(data.chsCertNo!=''){
			$("#chsCertNo").val(data.chsCertNo);//底盘合格证编号
		}
		if(data.fuelTyp!=''){
			$("#fuelTyp").val(data.fuelTyp);// 燃油种类
		}
		if(data.outVol!=''){
			$("#outVol").val(data.outVol);//排量（ml）
		}
		if(data.maxKw!=''){
			$("#maxKw").val(data.maxKw);//功率
		}
		if(data.oilCns!=''){
			$("#oilCns").val(data.oilCns);//油耗
		}
		if(data.outlineSz!=''){
			$("#outlineSz").val(data.outlineSz);//外廓尺寸（mm）
		}
		if(data.cntrSz!=''){
			$("#cntrSz").val(data.cntrSz);//货箱内部尺寸
		}
		if(data.leafSprNum!=''){
			$("#leafSprNum").val(data.leafSprNum);//钢板弹簧片数（片）
		}
		if(data.whlNum!=''){
			$("#whlNum").val(data.whlNum);//轮胎数
		}
		if(data.thread!=''){
			$("#thread").val(data.thread);//轮胎规格
		}
		if(data.whlSpec!=''){
			$("#whlSpec").val(data.whlSpec);//轮距(前/后)（mm）
		}
		if(data.whlBase!=''){
			$("#whlBase").val(data.whlBase);//轴距（mm）
		}
		if(data.axleLoad!=''){
			$("#axleLoad").val(data.axleLoad);//轴荷（kg）
		}
		if(data.axisNum!=''){
			$("#axisNum").val(data.axisNum);//轴数
		}
		if(data.strTyp!=''){
			$("#strTyp").val(data.strTyp);//转向形式
		}
		if(data.totWgt!=''){
			$("#totWgt").val(data.totWgt);//总质量
		}
		if(data.curbWgt!=''){
			$("#curbWgt").val(data.curbWgt);//整备质量
		}
		if(data.ratedWgt!=''){
			$("#ratedWgt").val(data.ratedWgt);//额定载质量
		}
		if(data.wgtCoe!=''){
			$("#wgtCoe").val(data.wgtCoe);//载质量利用系数
		}
		if(data.traTotWgt!=''){
			$("#traTotWgt").val(data.traTotWgt);//准牵引总质量
		}
		if(data.semiMaxWgt!=''){
			$("#semiMaxWgt").val(data.semiMaxWgt);//半挂车鞍座最大允许总质量
		}
		if(data.cabSeatQty!=''){
			$("#cabSeatQty").val(data.cabSeatQty);//驾驶室准乘人数
		}
		if(data.ratedSeatQty!=''){
			$("#ratedSeatQty").val(data.ratedSeatQty);//额定载客
		}
		if(data.maxSpd!=''){
			$("#maxSpd").val(data.maxSpd);//最高设计车速
		}
		if(data.proDt!=''){
			$("#proDt").val(DateUtils.formatDate(new Date(data.proDt), DateUtils.YYYY_MM_DD));//车辆制造日期
		}
		if(data.emiStd!=''){
			$("#emiStd").val(data.emiStd);//排放标准
		}

	}

	function getEditor(){
		// 专车客车事业部暂时未接入大数据平台，特殊处理
		if(StringUtils.isNotEmpty(cstMgrOrgCd) && cstMgrOrgCd.substr(0,12)=="000000080002"){
			return {type: 'text'};
		}else{
			return {
				type: 'popup', valueField: 'gpsCarNo', textField: 'gpsCarNo', width:300,
				grid:
				{
					data: gpsDevice,
					columns: [
						{ name: 'gpsCarNo', width: 200, display: 'GPS卡号' }
					],
					root:'rows',
					record:'total'
				},
				condition: {
					fields: [
						{ name: 'gpsCarNo', type: 'text', label: 'GPS卡号', width: 200 }
					]
				},
				searchClick: function (e)
				{
					//alert("这里可以根据搜索规则来搜索（下面的代码已经本地搜索),搜索规则:" + liger.toJSON(e.rules));
					e.grid.loadData($.ligerFilter.getFilterFunction(e.rules));
				}
			}
		}
	}


	$(function () {
		hideLink();
		var ligerForm = liger.get("prj_prd_veh_info_form");
		$("#prj_prd_veh_info_form").ligerForm({
			validate: true
		});
		// 初始GPS账号下设备
		// 专车客车事业部暂时未接入大数据平台，特殊处理
		if(StringUtils.isNotEmpty(cstMgrOrgCd) && cstMgrOrgCd.substr(0,12)!="000000080002"){
			var url = '<%=path%>/prjprddtlgps/prjPrdDtlGps/getGpsDevice.do?dtlId=' + dtlId + '&prjId = '+'${prjId}';
			$.ajax({
				type: 'get',
				dataType:'json',
				url: url,
				async:false, //同步请求，防止initGrid 时没有数据
				success:function(msg){
					if (msg.data != null) {
						gpsDevice = msg.data;
					}
				}
			});
		}
        /**
         * 修改页面，修改内容逻辑
         * 合格证审核状态（audStsCd，PRJ0112）：0-未审核， 2-审核通过
         * GPS审核状态（gpsAudStsCd，SYS0055）：0-未审核，1-审核中，2-审核通过，3-审核不通过，4-驳回呈报人
         *
         * 合格证与GPS都是未审核状态时，同时修改合格证与GPS信息；
         * 合格证未审核，GPS非 未审核状态，仅修改合格证信息
         * GPS未审核，合格证非 未审核状态，仅修改GPS
         *
         */

        if (typeof id != "undefined" && id != null && id != ""){// 合格证修改页面
            if (typeof gpsAudStsCd != "undefined"  && gpsAudStsCd != null && gpsAudStsCd != ""){
                if (gpsAudStsCd == 0 || gpsAudStsCd == 4){
                    buildGPSpage_update();
                }else{
                    buildGPSpage_query();
                }
            }else{
                // 如果合格证新增时没有填写GPS信息，在合格证修改时可以填写
                buildGPSpage_add();
            }
        }else{
            // 合格证新增页面,如果已有GPS卡号，则需要显示出来
            if (typeof gpsAudStsCd != "undefined"  && gpsAudStsCd != null && gpsAudStsCd != ""){
                if (gpsAudStsCd == 0 || gpsAudStsCd == 4){
                    buildGPSpage_update();
                }else{
                    buildGPSpage_query();
                }
            }else{
                buildGPSpage_add();
            }
        }

        if(isGpsNode == '1'){ //风控审批GPS节点 or 信审审核节点
            gpsInfoCfgGrid = $("#gpsInfoCfgGrid").ligerGrid({
                url: '<%=path%>/prjprddtlgps/prjPrdDtlGps/initGPSInfoList.do?prjDtlId=${dtlId}',
                method: 'get',
                columns: [
                    {display: 'GPS卡号', name: 'gpsCardNo', editor: {type: 'text'}, isAllowHide:false},
                    {display: 'GPS在线状态', name: 'onlineTypeNm'},
                    {display: '末次位置', name: 'gpsAddrInfo'},
                    {display: '经度', name: 'lng'},
                    {display: '纬度', name: 'lat'},
					{display: '末次时间', name: 'lastTm'},
					{display: '距离当前时间(小时)', name: 'fromLastTm'},
					{display: '设备类型', name: 'gpsDeviceType'},
					{display: '领用人工号', name: 'receiveName'},
					{display: '领用人姓名', name: 'receiveRealName'},
                    {display: '操作',
                        isSort: false,
                        width: 100,
                        align:'left',
                        render: function (rowdata, rowindex, value){
                            var h="";
                            h='<a class="sq-button-hasicon" href="javascript:recheckGPS(';
                            h+="'"+rowdata.gpsCardNo+"',";
                            h+="'"+rowindex+"'";
                            h+=')"><i class="sqBtnIco_4"></i>复查</a>';

                            return h;
                        }
                    }
                ],
				onBeforeEdit:function(e) {
					// 编辑之前
					gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
					gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
					gpsInfoCfgGrid.updateCell('lng', '', e.record);
					gpsInfoCfgGrid.updateCell('lat', '', e.record);
					gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
					gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
					gpsInfoCfgGrid.updateCell('gpsDeviceType', '', e.record);
					gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
					gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
				},
                onAfterEdit:function (e) {// 编辑结束后事件

					gpsCardNoAfterEdit(e);

					/*var reg = /^[0-9]+.?[0-9]*$/;
					var gpsCardNo = e.value;

					if (typeof gpsCardNo == "undefined" || gpsCardNo == null || gpsCardNo == "") {
						gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
						gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
						gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
						gpsInfoCfgGrid.updateCell('lng', '', e.record);
						gpsInfoCfgGrid.updateCell('lat', '', e.record);
						gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveWokeNum', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
					} else {
						// 校验GPS卡号必须是纯数字
						if (!reg.test(gpsCardNo)) {
							$.ligerDialog.SQalert({content: "GPS卡号仅支持15位纯数字", SQ_type: "warring"});
						} else {
							// 是纯数字，校验GPS卡号的长度
							if (gpsCardNo.length > 15) {
								$.ligerDialog.SQalert({content: "GPS卡号数字长度大于15", SQ_type: "warring"});
							} else {
								var isUsed = checkGpsIsUsed(gpsCardNo,dtlId);
								if (isUsed) {
									$.ligerDialog.SQalert({content: "该设备号已使用,请核查!", SQ_type: "warring"});
								} else {
									// 调用大数据查询gps设备信息
									var url = '<%=path%>/project/prjprdvehinfo/validateGpsDeviceInfo.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsCardNo: gpsCardNo,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg != null) {
												// 调用大数据返回正确信息
												if (msg.success == 1) {
													if (msg.info == null || msg.info == '') {
														// 客户经理和实际领用人一致，不显示确认框,显示信息
														if (msg.data != null) {
															gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
															gpsInfoCfgGrid.updateCell('receiveWokeNum', msg.data.receiveName, e.record);
															gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveRealName, e.record);
														} else {
															$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
														}
													} else {
														/!* success成功的情况下,info是不为空的，
                                                         *说明客户经理和实际领用人不一致,
                                                         * 要出现确认框
                                                         *!/
														$.ligerDialog.confirm(msg.info, function (flag) {
															if(!flag) {
																gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
																gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
																gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
																gpsInfoCfgGrid.updateCell('lng', '', e.record);
																gpsInfoCfgGrid.updateCell('lat', '', e.record);
																gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveWokeNum', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
																return;
															}

															// 点击是，也要显示信息
															if (msg.data != null) {
																gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
																gpsInfoCfgGrid.updateCell('receiveWokeNum', msg.data.receiveName, e.record);
																gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveRealName, e.record);
															} else {
																$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
															}
														});
													}

												} else {
													// 返回错误信息
													$.ligerDialog.SQalert({content: msg.info, SQ_type: "warring"});
												}
											} else {
												$.ligerDialog.SQalert({content: "DataResultVO为空", SQ_type: "warring"});
											}
										}
									});

									// 调用GPS位置第三方接口,把GPS信息更新到列表中
									var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsNum: newStr,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg.data != null){
												if(msg.data.onlineType == '0'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
												}else if(msg.data.onlineType == '1'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
												}else if(msg.data.onlineType == '2'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
												}
												gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
												gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
												gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
												gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
												gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
											}
										}
									});
								}
							}
						}
					}*/

                    /*var newStr = e.value;
                    // 验证逻辑：GPS卡号位数，15位以内(因历史数据问题，不限制数字还是字母或者特殊符号)，若超过15位,删除15位以后的字符
                    if (newStr.length > 15){
                        newStr = e.value.substring(0,15);
                        gpsInfoCfgGrid.updateCell('gpsCardNo', newStr, e.record)
                    }
                    if (typeof newStr == "undefined" || newStr == null || newStr == "") {
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
                        gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
                        gpsInfoCfgGrid.updateCell('lng', '', e.record);
                        gpsInfoCfgGrid.updateCell('lat', '', e.record);
						gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
                    } else {
                        // 调用GPS位置第三方接口,把GPS信息更新到列表中
                        var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
                        $.ajax({
                            type: 'get',
                            dataType:'json',
                            data:{gpsNum: newStr,dtlId:${dtlId}},
                            url: url,
                            success:function(msg){
                                if (msg.data != null) {
                                    if (msg.data.onlineType == '0') {
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
                                    } else if (msg.data.onlineType == '1') {
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
                                    } else if (msg.data.onlineType == '2') {
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
                                    }
                                    gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
                                    gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
                                    gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
									gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
									gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
                                }
                            }
                        });
                    }*/
                },
                root : 'rows',
                width : '100%',
                isScroll : true, //是否滚动
                rownumbers : true, //显示序号
                checkbox : false, //是否显示复选框
                allowUnSelectRow : true, //是否允许反选行
                alternatingRow : false, //奇偶行效果
                usePager : false,// 是否使用分页
                enabledEdit : true
            // 是否允许编辑
            });
            setReadOnly();
        }

        // 构建GPS查看页面
        function buildGPSpage_query() {
            gpsInfoCfgGrid = $("#gpsInfoCfgGrid").ligerGrid({
                url : '<%=path%>/prjprddtlgps/prjPrdDtlGps/initGPSInfoList.do?prjDtlId=${dtlId}',
                method: 'get',
                columns: [
                    {display: 'GPS卡号', name: 'gpsCardNo'},
                    {display: 'GPS在线状态', name: 'onlineTypeNm'},
                    {display: '末次位置', name: 'gpsAddrInfo'},
                    {display: '经度', name: 'lng'},
                    {display: '纬度', name: 'lat'},
                    {display: '末次时间', name: 'lastTm'},
					{display: '距离当前时间(小时)', name: 'fromLastTm'},
					{display: '设备类型', name: 'gpsDeviceType'},
					{display: '领用人工号', name: 'receiveName'},
					{display: '领用人姓名', name: 'receiveRealName'}
                ],
                root: 'rows',
                width: '100%',
                isScroll: false, //是否滚动
                rownumbers:true,  //显示序号
                checkbox: false, //是否显示复选框
                allowUnSelectRow:true,  //是否允许反选行
                alternatingRow: false, //奇偶行效果
                usePager: false,// 是否使用分页
                enabledEdit: true   // 是否允许编辑
            });
        }

        // 构建GPS修改页面
        function buildGPSpage_update() {
            gpsInfoCfgGrid = $("#gpsInfoCfgGrid").ligerGrid({
                url: '<%=path%>/prjprddtlgps/prjPrdDtlGps/initGPSInfoList.do?prjDtlId=${dtlId}',
                method: 'get',
                columns: [
                    /*{display: 'GPS序号', name: 'serialNo'},*/
                    {display: 'GPS卡号', name: 'gpsCardNo', editor: {type: 'text'}, enabledSort:true},
                    {display: 'GPS在线状态', name: 'onlineTypeNm'},
                    {display: '末次位置', name: 'gpsAddrInfo'},
                    {display: '经度', name: 'lng'},
                    {display: '纬度', name: 'lat'},
					{display: '末次时间', name: 'lastTm'},
					{display: '距离当前时间(小时)', name: 'fromLastTm'},
					{display: '设备类型', name: 'gpsDeviceType'},
					{display: '领用人工号', name: 'receiveName'},
					{display: '领用人姓名', name: 'receiveRealName'}
                ],
				onBeforeEdit:function(e) {
                  // 编辑之前
					gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
					gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
					gpsInfoCfgGrid.updateCell('lng', '', e.record);
					gpsInfoCfgGrid.updateCell('lat', '', e.record);
					gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
					gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
					gpsInfoCfgGrid.updateCell('gpsDeviceType', '', e.record);
					gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
					gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
				},
                onAfterEdit:function (e) {// 编辑结束后事件

					gpsCardNoAfterEdit(e);

					/*var reg = /^[0-9]+.?[0-9]*$/;
					var gpsCardNo = e.value;

					if (typeof gpsCardNo == "undefined" || gpsCardNo == null || gpsCardNo == "") {
						gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
						gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
						gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
						gpsInfoCfgGrid.updateCell('lng', '', e.record);
						gpsInfoCfgGrid.updateCell('lat', '', e.record);
						gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
					} else {
						// 校验GPS卡号必须是纯数字
						if (!reg.test(gpsCardNo)) {
							$.ligerDialog.SQalert({content: "GPS卡号仅支持15位纯数字", SQ_type: "warring"});
						} else {
							// 是纯数字，校验GPS卡号的长度
							if (gpsCardNo.length > 15) {
								$.ligerDialog.SQalert({content: "GPS卡号数字长度大于15", SQ_type: "warring"});
							} else {
								var isUsed = checkGpsIsUsed(gpsCardNo,dtlId);
								if (isUsed) {
									$.ligerDialog.SQalert({content: "该设备号已使用,请核查!", SQ_type: "warring"});
								} else {
									// 调用大数据查询gps设备信息
									var url = '<%=path%>/project/prjprdvehinfo/validateGpsDeviceInfo.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsCardNo: gpsCardNo,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg != null) {

												// 调用大数据返回正确信息
												if (msg.success == 1) {
													if (msg.info == null || msg.info == '') {
														// 客户经理和实际领用人一致，不显示确认框,显示信息
														if (msg.data != null) {
															gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
															gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveName, e.record);
															gpsInfoCfgGrid.updateCell('receiveRealName', msg.data.receiveRealName, e.record);
														} else {
															$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
														}
													} else {
														/!* success成功的情况下,info是不为空的，
                                                         *说明客户经理和实际领用人不一致,
                                                         * 要出现确认框
                                                         *!/
														$.ligerDialog.confirm(msg.info, function (flag) {
															if(!flag) {
																gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
																gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
																gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
																gpsInfoCfgGrid.updateCell('lng', '', e.record);
																gpsInfoCfgGrid.updateCell('lat', '', e.record);
																gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
																return;
															}

															// 点击是，也要显示信息
															if (msg.data != null) {
																gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
																gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveName, e.record);
																gpsInfoCfgGrid.updateCell('receiveRealName', msg.data.receiveRealName, e.record);
															} else {
																$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
															}
														});
													}

												} else {
													// 返回错误信息
													$.ligerDialog.SQalert({content: msg.info, SQ_type: "warring"});
												}
											} else {
												$.ligerDialog.SQalert({content: "DataResultVO为空", SQ_type: "warring"});
											}
										}
									});

									// 调用GPS位置第三方接口,把GPS信息更新到列表中
									var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsNum: newStr,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg.data != null){
												if(msg.data.onlineType == '0'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
												}else if(msg.data.onlineType == '1'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
												}else if(msg.data.onlineType == '2'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
												}
												gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
												gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
												gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
												gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
												gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
											}
										}
									});
								}
							}
						}
					}*/


                    /*// 验证逻辑：GPS卡号位数，15位以内(因历史数据问题，不限制数字还是字母或者特殊符号)，若超过15位,删除15位以后的字符
                    var newStr = e.value;
                    if (newStr.length > 15){
                        newStr = e.value.substring(0,15);
                        gpsInfoCfgGrid.updateCell('gpsCardNo', newStr, e.record)
                    }
                    if (typeof newStr == "undefined" || newStr == null || newStr == "") {
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
                        gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
                        gpsInfoCfgGrid.updateCell('lng', '', e.record);
                        gpsInfoCfgGrid.updateCell('lat', '', e.record);
                        gpsInfoCfgGrid.updateCell('useTypCdNm', '', e.record);
                    } else {
                        // 调用GPS位置第三方接口,把GPS信息更新到列表中
                        var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
                        $.ajax({
                            type: 'get',
                            dataType:'json',
                            data:{gpsNum: newStr,dtlId:${dtlId}},
                            url: url,
                            success:function(msg){
                                if (msg.data != null){
                                    if(msg.data.onlineType == '0'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
                                    }else if(msg.data.onlineType == '1'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
                                    }else if(msg.data.onlineType == '2'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
                                    }
                                    gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
                                    gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
                                    gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
									gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
									gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
                                }
                            }
                        });
                    }*/
                },
                root: 'rows',
                width: '100%',
                isScroll: false, //是否滚动
                rownumbers:true,  //显示序号
                checkbox: false, //是否显示复选框
                allowUnSelectRow:true,  //是否允许反选行
                alternatingRow: false, //奇偶行效果
                usePager: false,// 是否使用分页
                enabledEdit: true   // 是否允许编辑
            });
        }

        // 构建GPS新增页面
        function buildGPSpage_add() {
            var griddata = [{gpsCardNo:"",gpsStsCd:"",address:"",lng:"",lat:"",serialNo:"1"},{gpsCardNo:"",gpsStsCd:"",address:"",lng:"",lat:"",serialNo:"2"}
                ,{gpsCardNo:"",gpsStsCd:"",address:"",lng:"",lat:"",serialNo:"3"}];
            // GPS明细Grid
            gpsInfoCfgGrid = $("#gpsInfoCfgGrid").ligerGrid({
                columns: [
                    {display: 'GPS卡号', name: 'gpsCardNo', editor: {type: 'text'}, enabledSort:true},
                    {display: 'GPS在线状态', name: 'onlineTypeNm'},
                    {display: '末次位置', name: 'gpsAddrInfo'},
                    {display: '经度', name: 'lng'},
                    {display: '纬度', name: 'lat'},
					{display: '末次时间', name: 'lastTm'},
					{display: '距离当前时间(小时)', name: 'fromLastTm'},
					{display: '设备类型', name: 'gpsDeviceType'},
					{display: '领用人工号', name: 'receiveName'},
					{display: '领用人姓名', name: 'receiveRealName'}
                ],
                onAfterEdit:function (e) {// 编辑结束后事件

					gpsCardNoAfterEdit(e);
                    // 验证逻辑：GPS卡号位数，15位以内(因历史数据问题，不限制数字还是字母或者特殊符号)，超过15位,删除15位以后的字符
					/*var reg = /^[0-9]+.?[0-9]*$/;
					var gpsCardNo = e.value;

					if (typeof gpsCardNo == "undefined" || gpsCardNo == null || gpsCardNo == "") {
						gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
						gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
						gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
						gpsInfoCfgGrid.updateCell('lng', '', e.record);
						gpsInfoCfgGrid.updateCell('lat', '', e.record);
						gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
						gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
						gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
					} else {
						// 校验GPS卡号必须是纯数字
						if (!reg.test(gpsCardNo)) {
							$.ligerDialog.SQalert({content: "GPS卡号仅支持15位纯数字", SQ_type: "warring"});
						} else {
							// 是纯数字，校验GPS卡号的长度
							if (gpsCardNo.length > 15) {
								$.ligerDialog.SQalert({content: "GPS卡号数字长度大于15", SQ_type: "warring"});
							} else {
								var isUsed = checkGpsIsUsed(gpsCardNo,dtlId);
								if (isUsed) {
									$.ligerDialog.SQalert({content: "该设备号已使用,请核查!", SQ_type: "warring"});
								} else {
									// 调用大数据查询gps设备信息
									var url = '<%=path%>/project/prjprdvehinfo/validateGpsDeviceInfo.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsCardNo: gpsCardNo,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg != null) {

												// 调用大数据返回正确信息
												if (msg.success == 1) {
													if (msg.info == null || msg.info == '') {
														// 客户经理和实际领用人一致，不显示确认框,显示信息
														if (msg.data != null) {
															gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
															gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveName, e.record);
															gpsInfoCfgGrid.updateCell('receiveRealName', msg.data.receiveRealName, e.record);
														} else {
															$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
														}
													} else {
														/!* success成功的情况下,info是不为空的，
                                                         *说明客户经理和实际领用人不一致,
                                                         * 要出现确认框
                                                         *!/
														$.ligerDialog.confirm(msg.info, function (flag) {
															if(!flag) {
																gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
																gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
																gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
																gpsInfoCfgGrid.updateCell('lng', '', e.record);
																gpsInfoCfgGrid.updateCell('lat', '', e.record);
																gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
																gpsInfoCfgGrid.updateCell('deviceType', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
																gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
																return;
															}

															// 点击是，也要显示信息
															if (msg.data != null) {
																gpsInfoCfgGrid.updateCell('deviceType', msg.data.gpsDeviceType, e.record);
																gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveName, e.record);
																gpsInfoCfgGrid.updateCell('receiveRealName', msg.data.receiveRealName, e.record);
															} else {
																$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空", SQ_type: "warring"});
															}
														});
													}

												} else {
													// 返回错误信息
													$.ligerDialog.SQalert({content: msg.info, SQ_type: "warring"});
												}
											} else {
												$.ligerDialog.SQalert({content: "DataResultVO为空", SQ_type: "warring"});
											}
										}
									});

									// 调用GPS位置第三方接口,把GPS信息更新到列表中
									var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
									$.ajax({
										type: 'get',
										dataType:'json',
										data:{gpsNum: newStr,dtlId:${dtlId}},
										url: url,
										success:function(msg){
											if (msg.data != null){
												if(msg.data.onlineType == '0'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
												}else if(msg.data.onlineType == '1'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
												}else if(msg.data.onlineType == '2'){
													gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
												}
												gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
												gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
												gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
												gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
												gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
											}
										}
									});
								}
							}
						}
					}*/



					/*var newStr = e.value;
                    if (newStr.length > 15){
                        newStr = e.value.substring(0,15);
                        gpsInfoCfgGrid.updateCell('gpsCardNo', newStr, e.record)
                    }
                    if (typeof newStr == "undefined" || newStr == null || newStr == "") {
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
                        gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
                        gpsInfoCfgGrid.updateCell('lng', '', e.record);
                        gpsInfoCfgGrid.updateCell('lat', '', e.record);
                        gpsInfoCfgGrid.updateCell('useTypCdNm', '', e.record);
                    } else {
                        // 调用GPS位置第三方接口,把GPS信息更新到列表中
                        var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
                        $.ajax({
                            type: 'get',
                            dataType:'json',
                            data:{gpsNum: newStr,dtlId:${dtlId}},
                            url: url,
                            success:function(msg){
                                if (msg.data != null){
                                    if(msg.data.onlineType == '0'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
                                    }else if(msg.data.onlineType == '1'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
                                    }else if(msg.data.onlineType == '2'){
                                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
                                    }
                                    gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
                                    gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
                                    gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
									gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
									gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
                                }
                            }
                        });
                    }*/
                },
                data: {Rows: griddata, Total:3},
                width: '100%',
                isScroll: false, //是否滚动
                rownumbers:true,  //显示序号
                checkbox: false, //是否显示复选框
                allowUnSelectRow:true,  //是否允许反选行
                alternatingRow: false, //奇偶行效果
                usePager: false,// 是否使用分页
                enabledEdit: true   // 是否允许编辑
            });
        }

        if (buOrgCd == "00000013") {
            $("span[isValid='newEngery']").each(function () {
                $("input[isValid='newEngery']").each(function () {
                    $(this).attr("validate", "");
                });
                $(this).hide();
            });
        }
        if(audStsCd == 1 || audStsCd == 2){// 审核中、审核通过的合格证不能修改
            setReadOnly();
        }

        if(detailFlag =="true"){
            $("#prj_prd_veh_info_add_btn_id").hide();
            $("#addGps").hide();
            $("span[id='deleteButton']").each(function(){
                $(this).hide();
            });
        }

        setFormatDateValue();
        prjPrdVehImgList();
        //scanData();
    });


	/**
	 * 校验gps设备是否已使用
	 */
	function checkGpsIsUsed(gpsCardNo,dtlId) {
		/*true:已使用  false:未使用*/
		var isUsed = true;
		// gps设备是否使用
		var url = '<%=path%>/project/prjprddtl/checkGpsIsUsed.do';
		$.ajax({
			type: 'get',
			dataType:'json',
			data:{gpsCardNo: gpsCardNo,dtlId:dtlId},
			async:false,
			url: url,
			success:function(msg){
				if (msg != null) {
					// 调用大数据返回正确信息
					if (msg.success == 1 && msg.data != null) {
						// 0:占用 不调用大数据
						// 1:未占用 调用大数据
						if (msg.data == '1') {
							isUsed = false;
						}
					} else {
						// 返回错误信息
						$.ligerDialog.SQalert({content: "查看GPS设备信息是否占用异常", SQ_type: "warring"});
					}
				} else {
					$.ligerDialog.SQalert({content: "查看GPS设备信息是否占用异常", SQ_type: "warring"});
				}
			}
		});

		return isUsed;
	}

	/**
	 * 适用于输入完gps卡号之后，校验的信息
	 */
	function gpsCardNoAfterEdit(e) {
		var reg = /^[0-9]+.?[0-9]*$/;
		var gpsCardNo = e.value;

		if (typeof gpsCardNo == "undefined" || gpsCardNo == null || gpsCardNo == "") {
			gpsInfoCfgGrid.updateCell('gpsCardNo', '0', e.record);
			gpsInfoCfgGrid.updateCell('onlineTypeNm', '', e.record);
			gpsInfoCfgGrid.updateCell('gpsAddrInfo', '', e.record);
			gpsInfoCfgGrid.updateCell('lng', '', e.record);
			gpsInfoCfgGrid.updateCell('lat', '', e.record);
			gpsInfoCfgGrid.updateCell('lastTm', '', e.record);
			gpsInfoCfgGrid.updateCell('fromLastTm', '', e.record);
			gpsInfoCfgGrid.updateCell('gpsDeviceType', '', e.record);
			gpsInfoCfgGrid.updateCell('receiveName', '', e.record);
			gpsInfoCfgGrid.updateCell('receiveRealName', '', e.record);
		} else {
			if (gpsCardNo != '0') {
				// 校验GPS卡号必须是纯数字
				if (!reg.test(gpsCardNo)) {
					top.$.ligerDialog.SQalert({content: "GPS卡号仅支持15位纯数字",SQ_type: "error"});
				} else {
					// 是纯数字，校验GPS卡号的长度
					if (gpsCardNo.length !=15) {
						top.$.ligerDialog.SQalert({content: "GPS卡号数字长度不等于15",SQ_type: "error"});
					} else {
						var isUsed = checkGpsIsUsed(gpsCardNo,dtlId);
						if (isUsed) {
							top.$.ligerDialog.SQalert({content: "该设备号已使用,请核查!",SQ_type: "error"});
						} else {
							// 调用大数据查询gps设备信息
							var url = '<%=path%>/project/prjprdvehinfo/validateGpsDeviceInfo.do';
							var dataValidate = {};
							dataValidate.prjId = prjId;
							dataValidate.gpsCardNo=gpsCardNo;
							dataValidate.dtlId='${dtlId}';
							$.ajax({
								type: 'get',
								dataType:'json',
								data:dataValidate,
								url: url,
								success:function(msg){
									if (msg != null) {
										// 调用大数据返回正确信息
										if (msg.success == 1) {
											// 返回正确信息，回显姓名、工号、无线类型
											if (msg.data != null) {
												gpsInfoCfgGrid.updateCell('gpsDeviceType', msg.data.gpsDeviceType, e.record);
												gpsInfoCfgGrid.updateCell('receiveName', msg.data.receiveName, e.record);
												gpsInfoCfgGrid.updateCell('receiveRealName', msg.data.receiveRealName, e.record);

												// 显示经度、维度
												showLocations(gpsCardNo,e);
											} else {
												top.$.ligerDialog.SQalert({content: "查询GPS设备信息,调用大数据返回空",SQ_type: "error"});
											}

										} else {
											// 返回错误信息
											top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
										}
									} else {
										top.$.ligerDialog.SQalert({content: "DataResultVO为空",SQ_type: "error"});
									}
								}
							});


						}
					}
				}
			}
		}
	}


	function showLocations(gpsCardNo,e) {
			// 调用GPS位置第三方接口,把GPS信息更新到列表中
			var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
			$.ajax({
				type: 'get',
				dataType:'json',
				data:{gpsNum: gpsCardNo,dtlId:${dtlId}},
				url: url,
				success:function(msg){
					if (msg.data != null){
							if(msg.data.onlineType == '0'){
							gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', e.record);
						}else if(msg.data.onlineType == '1'){
							gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', e.record);
						}else if(msg.data.onlineType == '2'){
							gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', e.record);
						}
						gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, e.record);
						gpsInfoCfgGrid.updateCell('lng', msg.data.lng, e.record);
						gpsInfoCfgGrid.updateCell('lat', msg.data.lat, e.record);
						gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, e.record);
						gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, e.record);
					}
				}
			});
	}


	function setReadOnly(){
        $("#prdMdl").ligerGetTextBoxManager().setDisabled();
        $("#engMdl").ligerGetTextBoxManager().setDisabled();
        $("#engNo").ligerGetTextBoxManager().setDisabled();
        $("#certNo").ligerGetTextBoxManager().setDisabled();
        // liger.get('certDt').setDisabled();
        // liger.get('proDt').setDisabled();
        $("#certDt").ligerGetTextBoxManager().setDisabled();
        $("#proDt").ligerGetTextBoxManager().setDisabled();
        $("#mfrNm").ligerGetTextBoxManager().setDisabled();
        $("#vehBr").ligerGetTextBoxManager().setDisabled();
        $("#vehNm").ligerGetTextBoxManager().setDisabled();
        $("#vin").ligerGetTextBoxManager().setDisabled();
        $("#carCl").ligerGetTextBoxManager().setDisabled();
        $("#chsMdl").ligerGetTextBoxManager().setDisabled();
        $("#chsId").ligerGetTextBoxManager().setDisabled();
        $("#chsCertNo").ligerGetTextBoxManager().setDisabled();
        $("#fuelTyp").ligerGetTextBoxManager().setDisabled();
        $("#outVol").ligerGetTextBoxManager().setDisabled();
        $("#maxKw").ligerGetTextBoxManager().setDisabled();
        $("#oilCns").ligerGetTextBoxManager().setDisabled();
        $("#outlineSz").ligerGetTextBoxManager().setDisabled();
        $("#cntrSz").ligerGetTextBoxManager().setDisabled();
        $("#leafSprNum").ligerGetTextBoxManager().setDisabled();
        $("#whlNum").ligerGetTextBoxManager().setDisabled();
        $("#whlSpec").ligerGetTextBoxManager().setDisabled();
        $("#thread").ligerGetTextBoxManager().setDisabled();
        $("#whlBase").ligerGetTextBoxManager().setDisabled();
        $("#axleLoad").ligerGetTextBoxManager().setDisabled();
        $("#axisNum").ligerGetTextBoxManager().setDisabled();
        $("#strTyp").ligerGetTextBoxManager().setDisabled();
        $("#totWgt").ligerGetTextBoxManager().setDisabled();
        $("#curbWgt").ligerGetTextBoxManager().setDisabled();
        $("#ratedWgt").ligerGetTextBoxManager().setDisabled();
        $("#wgtCoe").ligerGetTextBoxManager().setDisabled();
        $("#traTotWgt").ligerGetTextBoxManager().setDisabled();
        $("#semiMaxWgt").ligerGetTextBoxManager().setDisabled();
        $("#cabSeatQty").ligerGetTextBoxManager().setDisabled();
        $("#ratedSeatQty").ligerGetTextBoxManager().setDisabled();
        $("#maxSpd").ligerGetTextBoxManager().setDisabled();
        $("#emiStd").ligerGetTextBoxManager().setDisabled();
        $("#dtlRem").ligerTextBox();
        $("#dtlRem").ligerGetTextBoxManager().setDisabled()
    }

    // 根据GPS卡号复查GPS信息
    function recheckGPS(gpsCardNo,rowIndex) {
        // 调用GPS位置第三方接口,把GPS信息更新到列表中
        var url = '<%=path%>/project/prjprdvehinfo/getGps.do';
        $.ajax({
            type: 'get',
            dataType:'json',
            data:{gpsNum: gpsCardNo,dtlId:${dtlId}},
            url: url,
            success:function(msg){
                if (msg.data != null){
                    if(msg.data.onlineType == '0'){
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '离线', rowIndex);
                    }else if(msg.data.onlineType == '1'){
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '在线', rowIndex);
                    }else if(msg.data.onlineType == '2'){
                        gpsInfoCfgGrid.updateCell('onlineTypeNm', '休眠', rowIndex);
                    }
                    gpsInfoCfgGrid.updateCell('gpsAddrInfo', msg.data.gpsAddrInfo, rowIndex);
                    gpsInfoCfgGrid.updateCell('lng', msg.data.lng, rowIndex);
                    gpsInfoCfgGrid.updateCell('lat', msg.data.lat, rowIndex);
					gpsInfoCfgGrid.updateCell('lastTm', msg.data.lastTm, rowIndex);
					gpsInfoCfgGrid.updateCell('fromLastTm', msg.data.fromLastTm, rowIndex);
                }
            }
        });
    }

    //验证合格证型号和项目产品型号是否一致
    function checkPrdMdl(){
        var prjPrdMdl = $("#prjPrdMdl").text();
        var prdMdl = $("#prdMdl").val();
        if(prjPrdMdl&&prdMdl){
            if(prjPrdMdl==prdMdl){
                $("#prdMdlText").html("  ");
            }else{
                $("#prdMdlText").text("租赁物型号和合格证型号不一致");
                $("#prdMdlText").css("color","red");
            }
        }
        return false;
    }
    function  uploadCallbackForMore(fileData,fileIndex){
        var sysCd="${sysCd}";
         var orgCd="${orgCd}";
         var cfgCd="${cfgCd}";
         var cfgDtlCd="${cfgDtlQtCd}";//其他资料

         var fileList = new Array();
         var params = {};
         if(fileIndex==4){
             cfgDtlCd="${cfgDtlCd}";
             params.dtlId="${dtlId}";
         }
         for(var i = 0; i < fileData.length;i++){
          var obj = {};
              obj.fileNm=fileData[i].fileNm;
              obj.filePath=fileData[i].filePath;
              obj.pkId = dtlId;
              obj.sysCd= sysCd;
              obj.orgCd= orgCd;
              obj.cfgCd =cfgCd;
              obj.cfgDtlCd =cfgDtlCd;
              fileList.push(obj);
         }

        params.sysCd= sysCd;
        params.orgCd= orgCd;
        params.cfgCd =cfgCd;
        params.cfgDtlCd =cfgDtlCd;
        params["fileList"] = JSON.stringify(fileList);
        var url = '<%=path%>/project/prjprdvehinfo/addProjectPhoto.do';
        $.ajax({
            type: 'post',
            dataType:'json',
            data:params,
            url: url,
            success:function(msg){
                 if(msg.success == 1){
                     //top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                     if(msg.data && msg.data.cfgDtlCd=="${cfgDtlCd}"){
                        absLocPath= msg.data.absLocPath;
                        //ocrVeh(1);取消上传就自动识别功能
						 chgFileFlag=true;
                     }
                     prjPrdVehImgList();
                 }else{
                     top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                 }
            }
        });
    }

    //验证发动机型号和项目发动机型号是否一致
    function checkEngMdl(){
        var prjEngMdl = $("#prjEngMdl").text();
        var engMdl = $("#engMdl").val();
        if(prjEngMdl&&engMdl){
            if(prjEngMdl==engMdl){
                $("#engMdlText").html("  ");
            }else{
                $("#engMdlText").text("租赁物发动机型号和合格证发动机型号不一致");
                $("#engMdlText").css("color","red");
            }
        }
        return false;
    }

    function prjDetailBtn(id){
        var fromPrjFlag = true;
        var detailFlag = true;
        var _flag = $("#fromPrjFlagId").val();
        if(StringUtils.isNotEmpty(_flag)){
            if(_flag == 'false'){
                fromPrjFlag = false;
            }
        }
        Add_navTab('tab_project_detail'+id,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag='+fromPrjFlag+'&&id='+id+'&&detailFlag='+detailFlag);
    }

    function prjPrdVehImgList(){
        var dtlId = '${dtlId}';
        var params = {};
        params.dtlId = dtlId;
        //params.cfgDtlCd="${cfgDtlQtCd}";//其他资料
        var url = '<%=path%>/project/prjprdvehinfo/getPrjPrdVehImgList.do';
        $.ajax({
            type: 'post',
            dataType:'json',
            data:params,
            url: url,
            success:function(msg){
                 if(msg.success == 1){
                     if(msg.data&&msg.data.length>0){
                         initImgData(msg.data);
                     }
                 }
            }
        });
    }

    function initImgData(data){
         var flag=0;
         if(data&&data.length>0){
              var html = "";
              html+="<tr>";
              var  html4="<tr>";
              for(var i=0;i<data.length;i++){
                  var file = data[i];
                  var html2="";
                  if((i+1)%4==0){
                      html2+="</tr>";
                      html2+="<tr>";
                  }
                  html2+="<td>";
                  html2+="<div class='imgBox'>";
                  html2+="<img id='imgPath'  src='"+file.filePath+"' onclick='scanData(this,event);' href='"+file.filePath+"'>";
                  html2+="</div>";
                  html2+="</td>";
                //合格证跟其他分开
                  if(file.cfgDtlCd=="${cfgDtlCd}"){
                      html4+=html2;
                      flag=4;
                      absLocPath= file.absLocPath;
                  }else{
                      html+=html2;
                  }
              }
              html+="</tr>";
              html4+="</tr>";
              if(flag==4){
                  $("#imgTable4").html(html4);
              }
              $("#imgTable").html(html);
        }
    }

    function payDetailBtn(prjPrdDtlId,id,prjPrdId,prjId){
        if(null==id){
            id = "";
        }
        if(null==prjPrdDtlId){
            prjPrdDtlId = "";
        }
        if(null==prjPrdId){
            prjPrdId = "";
        }
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
    }
    //设置日期值
    function setFormatDateValue(){
        var certDt ='${vehInfo.certDt}';
        if(certDt){
            var certDate = DateUtils.formatDate(new Date(certDt),DateUtils.YYYY_MM_DD);
            $("#certDt").val(certDate);//
            $("#certDtTxt").text(certDate);
        }
        var proDt ='${vehInfo.proDt}';
        if(proDt){
            var proDate= DateUtils.formatDate(new Date(proDt),DateUtils.YYYY_MM_DD);
            $("#proDt").val(proDate);//
        }
    }

    function scanData(img,event){
        event.preventDefault();
        var href = $(img).attr('src');
        if (SQ.regs.img.test(href)) {
            SQ.imgPreview(href);
        }else{
            alert('不是图片');
        };
    }
    function validateVin(input){
        var vin = $(input).val();
        if(StringUtils.isEmpty(vin)){
            $("#vinValidationResult").html("未校验");
            $("#vinValidRes").val("0");
        }else {
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: {vin: vin,prdTypCd:'${prdTypCd}'},
                url: '<%=path%>/project/prjprddtl/validVin.do',
                success: function (msg) {
                    $("#vinValidRes").val(msg.success);
                    $("#vinValidationResult").html(msg.info);
                }
            });
        }
    }
	function save(){
        var GPSstr = gpsInfoCfgGrid.getData();
        var ligerForm = liger.get("prj_prd_veh_info_form");
        if (!ligerForm.valid()) {
			wait_dialog.close();
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }

        var gpsNums = "";
        if (typeof GPSstr != "undefined" && null != GPSstr && "" != GPSstr){
            for (var i = 0; i < GPSstr.length; i++){
                if (GPSstr[i]['gpsCardNo'] == null || GPSstr[i]['gpsCardNo'] == '') {
                    gpsNums += "0" +","// 如果GPS卡号没有填写，默认0
				} else {
                    gpsNums += GPSstr[i]['gpsCardNo'] +","
				}
            }
        }

        var data = ligerForm.getData();
        //验证vin是否重复
        var url = '<%=path%>/project/prjprdvehinfo/add.do';
        var id = $("#vehInfo").val();
        data["id"]= $("#vehId").val();
        data["dtlId"]= dtlId;
        data["lnkCompId"]=$("#lnkCompId").val();
        data["audStsCd"]= audStsCd;// 合格证审核状态
        data["gpsAudStsCd"]= gpsAudStsCd;// GPS审核状态
        data["isGpsNode"]= isGpsNode;// 是否风控审批GPS节点，0-否，1-是
		data["gpsNums"] = gpsNums;
        data["vinValidRes"] = $("#vinValidRes").val();
        data["prjPrdChangeFlag"] = prjPrdChangeFlag;
		data["prjId"] = prjId;

		var dataValidate = {};
		if (typeof GPSstr != "undefined" && null != GPSstr){
			for (var i = 0; i < GPSstr.length; i++){
				if(GPSstr[i]['serialNo'] == "1"){
					dataValidate.gps1 = GPSstr[i]['gpsCardNo'];
				}
				if(GPSstr[i]['serialNo'] == "2"){
					dataValidate.gps2 = GPSstr[i]['gpsCardNo'];
				}
				if(GPSstr[i]['serialNo'] == "3"){
					dataValidate.gps3 = GPSstr[i]['gpsCardNo'];
				}

			}
		}
		dataValidate.dtlId = dtlId;
		dataValidate.prjId = prjId;

		console.log(dataValidate)

        // 校验接口
		$.ajax({
			type: 'post',
			dataType:'json',
			data:dataValidate,
			url: '<%=path%>/project/prjprdvehinfo/validateGps.do',
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					if (msg.info != '' && msg.info != null) {
						// 说明要弹出确认框
						$.ligerDialog.confirm(msg.info, function (flag) {
							/* 点击是，做保存
                            *  点击否，显示原来的信息
                            * */
							if(!flag) {
								return;
							}
							saveGps(url,data);
						});
					} else {
						saveGps(url,data);
					}
				}else{
					wait_dialog.close();
					UIUtils.alertErrorHold1(msg.info);
				}
			}
		});
	}


	function saveGps(url,data) {
		$.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					$("#vehId").val(msg.data);
					top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
					var TAB=top.mainApp.parentTab;
					var currentTabid=TAB.getSelectedTabItemID();
					var currFrameElement=top.$("#"+currentTabid).get(0);
					var callback=currFrameElement.W2W.callback;
					callback();
					top.tab.removeTabItem(currentTabid);
				}else{
					top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
				}
			}
		});
	}


	function savePrjPrdVin(){
		wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		var ligerForm = liger.get("prj_prd_veh_info_form");
        if (!ligerForm.valid()) {
            wait_dialog.close();
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }

        var vin = $("#vin").val();
        var id = $("#vehId").val();
        var beforeVin = '${vehInfo.vin}';
		//验证历史数据中有没有相同的车架号
	    if("ZRZYW" == prjTypCd) {
            //已正常结清/已提前结清/已强制结清/已处置/优车已处置/已赎回结清/已拖回/已转优车/无法拖回
            if(prdStsCd == 'S010301' || prdStsCd == 'S010401' || prdStsCd == 'S010501'  || prdStsCd =='S0106020101'|| prdStsCd =='S01060203010101' || prdStsCd  == 'S0106020201' || prdStsCd  =='S010602'  ||  prdStsCd=='S0106020301' || prdStsCd =='S010601' ){
                if(vin == LSvin){
                     save();
                }else{
                    save();
                }
            } else {//不是指定资产状态
                if ((!id && vin) || (beforeVin && beforeVin != vin)) {
                    var url = '<%=path%>/project/prjprdvehinfo/checkPrjPrdVehVinExist.do';
                    $.ajax({
                        type: 'get',
                        dataType: 'json',
                        data: {vin: vin, dtlId: dtlId},
                        url: url,
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                UIUtils.alertError(vin + "，该车架号已经存在！");
                            }
                            if (msg.success == 0) {
                                save();
                            }
                        }
                    });
                } else {
                    save();
                }
            }
		} else {//不是再融资
			if((!id && vin) || (beforeVin && beforeVin != vin)) {
                var url = '<%=path%>/project/prjprdvehinfo/checkPrjPrdVehVinExist.do';
                $.ajax({
                    type: 'get',
                    dataType:'json',
                    data:{vin:vin},
                    url: url,
                    success:function(msg){
                        wait_dialog.close();
                         if(msg.success == 1){
                             UIUtils.alertError(vin+"，该车架号已经存在！");
                         }
                         if(msg.success == 0){
                             save();
                         }
                    }
                });
            } else {
                save();
            }
		}
	}
	
	
	function uploadFile(imgObj,sysCd,orgCd,cfgCd,cfgDtlCd){
		var obj = $(imgObj).parent().parent().find("img")
		var dtlId = '${dtlId}';
		var  url = '<%=path%>/project/prjprdvehinfo/addPrjPrdImgPage.do?sysCd='+sysCd+'&&orgCd='+orgCd+'&&cfgCd='+cfgCd+'&&cfgDtlCd='+cfgDtlCd+'&&dtlId='+dtlId;
		$.ligerDialog.open({
            height:300,
            width: 600,
            title : '上传图片',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
            	imgObj: obj
            }
        });
	}
	
	function choosePrjLnkComp(){
        $.ligerDialog.open({  title: '更改产品挂靠公司',height: 500,width: 850, url:'<%=path%>/project/prjprdvehinfo/toChooseLnkCompPage.do'});
	}
	function clearLnkComp(){
		if($("#lnkCompId").val()==''){
            return;
        }
		var url = '<%=path%>/project/prjprddtl/removePrdDtlLnkCompByIds.do';
	    $.ajax({
    		type: 'post',
    		dataType:'json',
    		data:{ids:'[${dtlId}]'},
    		url: url,
    		success:function(msg){
				
    			 if(msg.success == 1){
    				 top.$.ligerDialog.SQalert({content: "移除挂靠公司成功",SQ_type: "success"});
    				 $("#lnkCompId").val('');
    				 $("#lnkCompNm").val('');
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
</script>
</body>
</html>